import { _decorator, Component, Node, Vec2 } from 'cc';
import { MAP_HEIGHT, MAP_WIDTH, SIZE } from './snakeMgr';
const { ccclass, property } = _decorator;

@ccclass('food1')
export class food1 extends Component {
    private pos: Vec2 = new Vec2(0, 0);

    randomPos():Vec2 {
        this.pos.x = Math.floor(Math.random() * MAP_WIDTH) * SIZE + SIZE / 2;
        this.pos.y = Math.floor(Math.random() * MAP_HEIGHT) * SIZE + SIZE / 2;
        this.node.setPosition(this.pos.x, this.pos.y);
        return this.pos;
    }
}


